﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;

namespace Gencode.PrsCommon.ControlData.GridControl
{
	/// <summary>
	/// PlanGridGenerator is used in PrsWeb
	/// This class can't be removed before PrsWeb is not changed
	/// </summary>
	public class PlanNameGrid
	{
		public PlanNameGrid()
		{
		}

		public DataTable Table
		{
			get;
			set;
		}

		public void AddItem(string value)
		{
			if (Table == null)
				InitTable();

			DataRow row = Table.NewRow();
			row["Name"] = value;
			Table.Rows.Add(row);
		}

		public void AddItem()
		{
			if (Table == null)
				InitTable();

			DataRow row = Table.NewRow();
			row["Name"] = "";
			Table.Rows.Add(row);
		}

		public void InitTable()
		{
			Table = new DataTable();
			Table.Columns.Add("Name", typeof(string));
		}

		public void CreatePersonenGridForPlan(DataView data)
		{
			DataTable dt = new DataTable();
			dt.Columns.Add("Name", typeof(string));

			foreach (DataRowView row in data)
			{
				DataRow dr = dt.NewRow();
				dr["Name"] = row[1].ToString() + " " + row[2].ToString();
				dt.Rows.Add(dr);
			}

			Table = dt;
		}
	}
}
